package com.demo.java.config;

import com.demo.java.service.BeanService;
import com.demo.java.service.impl.BeanOne;
import com.demo.java.service.impl.BeanTwo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Slf4j
@Configuration
public class BeanServiceConfig {

    @Bean
    @ConditionalOnProperty(value = "bean.type", havingValue = "one")
    public BeanService beanOne() {
        log.info("create bean one");
        return new BeanOne();
    }

    @Bean
    @ConditionalOnProperty(value = "bean.type", havingValue = "two")
    public BeanService beanTwo() {
        log.info("create bean two");
        return new BeanTwo();
    }
}
